package com.asset.dispoal.file.document;

import com.asset.dispoal.file.document.api.DocumentService;
import com.asset.dispoal.file.document.dto.DocumentAddRequest;
import com.asset.dispoal.file.document.dto.DocumentPageRequest;
import com.asset.dispoal.file.document.dto.DocumentPageResponse;
import com.asset.dispoal.file.document.dto.DocumentTypeAddRequest;
import com.asset.dispoal.file.document.dto.DocumentTypePageRequest;
import com.asset.dispoal.file.document.dto.DocumentTypePageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.permission.annotation.Permission;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

@RestController
@Api(value = "司法文书管理", tags = "司法文书管理")
@RequestMapping("file/document")
public class DocumentController {

    @Autowired
    private DocumentService documentService;

    @Permission(code = "documentType:add")
    @PostMapping("insertType")
    @ApiOperation(value = "司法文书类型写入", notes = "司法文书类型写入")
    public Result insertType(DocumentTypeAddRequest request) {
        return documentService.insertType(request);
    }

    @Permission(code = "documentType:del")
    @DeleteMapping("deleteType")
    @ApiOperation(value = "司法文书类型删除", notes = "司法文书类型删除")
    public Result deleteType(String id) {
        return documentService.deleteType(id);
    }

    @Permission(code = "documentType:query", param = "create_user_id")
    @GetMapping(value = "/queryTypePage")
    @ApiOperation(value = "司法文书类型分页查询", notes = "司法文书类型分页查询")
    public Result<PageVO<DocumentTypePageResponse>> queryTypePage(DocumentTypePageRequest request) {
        return documentService.queryTypePage(request);
    }

    @Permission(code = "documentType:query")
    @GetMapping(value = "/getTypeById")
    @ApiModelProperty(value = "司法文书类型单个查询", notes = "司法文书类型单个查询")
    public Result<DocumentTypePageResponse> getTypeById(String id) {
        return documentService.getTypeById(id);
    }

    @PostMapping(value = "insert")
    @ApiOperation(value = "司法文书插入", notes = "司法文书插入")
    public Result insert(DocumentAddRequest documentAddRequest) {
        return documentService.insert(documentAddRequest);
    }

    @DeleteMapping(value = "delete")
    @ApiOperation(value = "司法文书删除", notes = "司法文书删除")
    public Result delete(String id) {
        return documentService.delete(id);
    }

    @GetMapping(value = "queryPage")
    @ApiOperation(value = "司法文书分页", notes = "司法文书分页")
    public Result<PageVO<DocumentPageResponse>> queryPage(DocumentPageRequest request) {
        return documentService.queryPage(request);
    }
}
